package cn.yunhe.servlet;


import cn.yunhe.entity.LeaveMessage;
import cn.yunhe.entity.leaveMess;
import cn.yunhe.service.LeaveMessageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/ReplyLeaveMessageServlet")
public class ReplyLeaveMessageServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

       String lea = request.getParameter("leaveId");
       int leaveid =Integer.parseInt(lea);
        String replycontent = request.getParameter("replycontent");

        leaveMess leavem= new leaveMess();
        leavem.setLeaveId(leaveid);
        leavem.setReplycontent(replycontent);



        /*eaveMessage leaveMessage = new LeaveMessage();
        leaveMessage.setLeaveContent(replycontent);

        leaveMessage.setLeaveId(leaveid);*/
        LeaveMessageService leaveMessageService = new LeaveMessageService();
        boolean flag = leaveMessageService.updateLeavemessage(leavem);
        if (flag) {
            response.sendRedirect("GetLeaveMessageServlet");
        }
        response.setContentType("text/html; charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<script>回复失败</script>");


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
